Fannie Mae mortgage data¶
Import cuXfilter¶
[1]:
from cuXfilter import charts
import cuXfilter
from bokeh import palettes
from cuXfilter.layouts import *
from bokeh.tile_providers import get_provider as gp
tile_provider = gp('STAMEN_TONER')
Define charts¶
[3]:
cux_df = cuXfilter.DataFrame.from_arrow('../../../data/146M_predictions_v2.arrow')
[4]:
chart0 = charts.bokeh.choropleth(x='zip', y='delinquency_12_prediction', aggregate_fn='mean', geo_color_palette=palettes.Purples9,
geoJSONSource = 'https://raw.githubusercontent.com/rapidsai/cuxfilter/master/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json',
tile_provider=tile_provider, data_points=1000)
chart2 = charts.bokeh.bar('delinquency_12_prediction',data_points=50)
chart3 = charts.panel_widgets.range_slider('borrower_credit_score',data_points=50)
Add mappings for chart1¶
[5]:
mapper1 = {}
for val in cux_df.data.dti.unique().to_pandas().tolist():
mapper1[int(val)] = 'l_'+str(val)
chart1 = charts.panel_widgets.drop_down('dti', label_map=mapper1)
#also available: panel_widgets.multi_select
Create a dashboard object¶
[6]:
d = cux_df.dashboard([chart0, chart1], layout=feature_and_base, theme=cuXfilter.themes.dark, title="Fannie Mae mortgage Dashboard")
[7]:
#add more charts
d.add_charts([chart2, chart3])
[8]:
#dashboard object
d
[8]:
Starting the dashboard¶
d.show(‘url you want the dashboard to run’) remote dashboard
d.app(‘10.110.47.43:8888’) within the notebook: If you are using jupyter remotely, use this line instead of second, and replace url with current notebook url
[9]:
# preview the dashboard
await d.preview()
Export the queried data into a dataframe¶
[10]:
queried_df = d.export()
no querying done, returning original dataframe